package ext.acae2.dms.validator;

import wt.org.WTGroup;
import wt.org.WTPrincipal;
import wt.util.WTException;

import com.ptc.core.ui.validation.DefaultSimpleValidationFilter;
import com.ptc.core.ui.validation.UIValidationCriteria;
import com.ptc.core.ui.validation.UIValidationKey;
import com.ptc.core.ui.validation.UIValidationStatus;

import ext.acae2.utilities.principal.CSCPrincipal;

/**
 * @desription Administrator data import way filter 
 * @author cnie
 * @date 2013-3-21 下午1:33:27
 */
public class DataImportFilter extends DefaultSimpleValidationFilter{

	@Override
	public UIValidationStatus preValidateAction(UIValidationKey uiValidationKey,
			UIValidationCriteria uiValidationCriteria) {
		UIValidationStatus status = UIValidationStatus.HIDDEN;
		
		try {
			WTPrincipal currentUser = uiValidationCriteria.getUser().getPrincipal();
			WTGroup adminGroup = CSCPrincipal.getGroupByName("Administrators");
			if(adminGroup.isMember(currentUser)){
				status = UIValidationStatus.ENABLED;
			}
		} catch (WTException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return status;
	}
	
	

}
